package com.jprocms.module.cms.controller.admin.vote.vo;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Date;

import static com.jpro.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

/**
 * 投票 Base VO，提供给添加、修改、详细的子 VO 使用
 * 如果子 VO 存在差异的字段，请不要添加到这里，影响 Swagger 文档生成
 */
@Data
public class VoteBaseVO {

    @Schema(description = "站点ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3966")
    private Long siteId;

    @Schema(description = "标题", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "标题不能为空")
    @DiffLogField(name = "标题")
    private String title;

    @Schema(description = "描述", example = "你说的对")
    @DiffLogField(name = "描述")
    private String description;

    @Schema(description = "开始日期")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    @DiffLogField(name = "开始日期")
    private Date beginDate;

    @Schema(description = "结束日期")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    @DiffLogField(name = "结束日期")
    private Date endDate;

    @Schema(description = "重复投票间隔天数(0:不可重复投票)", requiredMode = Schema.RequiredMode.REQUIRED)
    @DiffLogField(name = "重复投票间隔天数")
    private Integer voteInterval;

    @Schema(description = "参与人次", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer voteNum;

    @Schema(description = "模式(1:独立访客,2:独立IP,3:独立用户)", requiredMode = Schema.RequiredMode.REQUIRED)
    @DiffLogField(name = "模式")
    private Short voteMode;

    @Schema(description = "是否多选", requiredMode = Schema.RequiredMode.REQUIRED)
    @DiffLogField(name = "是否多选")
    private Boolean voteMultiple;

    @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED)
    @DiffLogField(name = "是否启用")
    private Boolean enabled;

    @Schema(description = "创建人ID", example = "16241")
    private Long userId;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
}
